/**
 * 返回当前集合中指定位置的元素
 * zjw
 * 计时器
 * 格式：00:00:00:0000毫秒；
 * 支持暂停，重置
 */
let hour,minute,second;//时 分 秒
hour=minute=second=0;//初始化
let millisecond=0;//毫秒
let int;
function Reset(){//重置
	window.clearInterval(int);
	millisecond=hour=minute=second=0;
	document.getElementById('timetext').value='00:00:00';
}
export const start = function(){//开始
	hour=minute=second=0;//初始化
	int=setInterval(timer,1000);
}
export const timer = function(){//计时
	millisecond=millisecond+1000;
	if(millisecond>=1000){
		millisecond=0;
		second=second+1;
	}
	if(second>=60){
		second=0;
		minute=minute+1;
	}
	if(minute>=60){
		minute=0;
		hour=hour+1;
	}
	// if(minute<10){
	// 	minute = '0'+minute
	// }
	// if(hour.length<2){
	// 	hour = '0'+hour
	// }
	// if(minute.length<2){
	// 	minute = '0'+minute
	// }
	// if(second.length<2){
	// 	second = '0'+second
	// }
	// document.getElementById('timetext').value=hour+':'+minute+':'+second+':'+millisecond+'毫秒';
	// document.getElementById('timetext').value=hour+':'+minute+':'+second;
	// console.log(hour,minute,second)
	return hour+':'+minute+':'+second;
}
export const getTimeNow = function(){
	let a='',b='',c='';
	if(hour<10){
		a = "0"+hour
	}else{
		a = hour
	}
	if(minute<10){
		b = "0"+minute
	}else{
		b = minute
	}
	if(second<10){
		c = "0"+second
	}else{
		c = second
	}
	let time = a+':'+b+':'+c
	return time
}
export const stop = function(){//暂停
	window.clearInterval(int);
}
{/* <div style="text-align: center">
 <input type="text" id="timetext" value="00时00分00秒" readonly><br>
 <button type="button" onclick="start()">开始</button> <button type="button" onclick="stop()">暂停</button> <button type="button" onclick="Reset()">重置</button>
</div> */}
